Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dialog requestClose() to handle edge case #10983

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

lukewarlow
Copy link
Member

@lukewarlow lukewarlow commented Feb 2, 2025

Fix dialog requestClose() to handle edge case

Dialog requestClose() now directly calls close the dialog if dialog's close watcher is null.

This replaces a previous assert that's wrong.

(See WHATWG Working Mode: Changes for more details.)


/interactive-elements.html ( diff )

@lukewarlow lukewarlow marked this pull request as ready for review February 2, 2025 23:53
@lukewarlow lukewarlow force-pushed the fix-dialog-requestclose branch from 67f78ff to bc0f5ec Compare February 2, 2025 23:56
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is more temporary patches since we haven't fixed the asymmetry between setting open and calling show().

@mfreed7 PTAL?

@lukewarlow
Copy link
Member Author

I guess this is more temporary patches since we haven't fixed the asymmetry between setting open and calling show().

Yeah idk what the end result we want is, perhaps we can change this to an assert in future and make sure close watcher is created when open is added but for now this seems like the minimal fix to prevent a crash.

I think it's potentially worth a discussion at whatnot about what we envisage the end state to be for the open attribute because it causes many an issue so it might be worth spending time fully fixing it up.

Dialog requestClose() now directly calls close the dialog if dialog's close watcher is null.

This replaces a previous assert that's wrong.
@lukewarlow lukewarlow force-pushed the fix-dialog-requestclose branch from bc0f5ec to e2f7801 Compare February 3, 2025 12:20
@mfreed7
Copy link
Contributor

mfreed7 commented Feb 7, 2025

So I just put up a patch in Chromium to fix (I think all?) of these crasher/assert cases. Instead of relaxing the asserts, it adds attribute change steps for open that construct the close watcher and add the dialog to the open dialogs list when the open attribute is added to the <dialog>. WDYT about that approach, instead of the one in this PR?

@lukewarlow
Copy link
Member Author

lukewarlow commented Feb 7, 2025

Provided there's no unexpected behaviour (such as the dialog being added to the list (set in chrome so might not be noticed) twice when calling show() and showModal()) I think that's preferable. Would solve the initially open case too.

For the sake of completeness I think it should match :open too. I know that's not a spec concern but it would be good to add a WPT to ensure it's synced to the attribute correctly. (Likewise when removing the open attribute)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

3 participants